//
//  WQCMyTeamViewController.m
//  renxinghuan
//
//  Created by 王晓民 on 2018/3/23.
//  Copyright © 2018年 吴清翠. All rights reserved.
//

#import "WQCMyTeamViewController.h"
#import "configuration.h"
#import "teamModel.h"
#import "teamTableViewCell.h"
@interface WQCMyTeamViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,retain) UITableView      *tableView;
@property(nonatomic,strong)NSMutableArray  *teamArr;

@end

@implementation WQCMyTeamViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    self.teamArr=[[NSMutableArray alloc]init];
    [self setupNav];
    [self loadmyteam];
    [self setupTableView];


}

#pragma make -------->>setNav
- (void)setupNav {
    self.navigationItem.title = @"我的团队";
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    [self.navigationController.navigationBar setBarTintColor:wycMain];
    
    self.view.backgroundColor = WYCGlobalBg;
}
- (void)loadmyteam {
    [HttpTool POST:myTeam params:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSLog(@"%@",responseObject);
        if ([[responseObject objectForKey:@"code"] intValue] == 0) {
            
            NSArray *result = [responseObject objectForKey:@"result"];
            for (NSDictionary * dict in result) {
                teamModel * messegeModel = [teamModel mj_objectWithKeyValues:dict];
                [self.teamArr addObject:messegeModel];
            }
        }
        [self.tableView reloadData];
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
    }];

}
- (void)ObtainButton{
    
    UILabel * label = [[UILabel alloc] init];
    label.text = @"暂无消息";
    label.textAlignment = NSTextAlignmentCenter;
    label.font = [UIFont systemFontOfSize:MiddleFont];
    label.frame = CGRectMake(0, ScreenHeight/2, ScreenWidth, 60);
    label.textColor = WYCRGBColor(200, 200, 200);
    [self.view  addSubview:label];
}
//表视图
- (void)setupTableView
{
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavHeight, ScreenWidth, ScreenHeight) style:UITableViewStylePlain];
    self.tableView.tableFooterView = [[UIView alloc] init];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.backgroundColor = WYCGlobalBg;
    
    [self.view addSubview:self.tableView];
    
}

//Nav按钮及颜色
- (void)setupNavButton{
    self.navigationItem.title = @"收支明细";
    self.view.backgroundColor = WYCGlobalBg;
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    [self.navigationController.navigationBar setBarTintColor:wycMain];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.teamArr.count;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    return 250 * px;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString * strID = @"cell";
    
    teamTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:strID];
    
    if (cell == nil)
    {
        cell=[[[NSBundle mainBundle]loadNibNamed:@"teamTableViewCell" owner:self options:nil]lastObject];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    teamModel * model = self.teamArr[indexPath.row];
    
    if (model.payUserName.length==0) {
        cell.titleLb.text = @"未实名";
    }
    else
    {
        cell.titleLb.text =model.payUserName;
    }
    cell.contenLb.text =model.comment;
    cell.moneylB.text =model.amount;
    cell.dateLb.text =model.createTime;
    
    return cell;
}



@end
